package com.dt.platform.generator.module.oa;

import com.dt.platform.constants.db.OaTables;
import com.dt.platform.constants.enums.common.FlowProcessStatusEnum;
import com.dt.platform.constants.enums.oa.FinCollectStatusEnum;
import com.dt.platform.constants.enums.oa.FinPaymentStatusEnum;
import com.dt.platform.domain.oa.FinCompanySubject;
import com.dt.platform.domain.oa.FinPaymentNoTicket;
import com.dt.platform.domain.oa.Project;
import com.dt.platform.domain.oa.meta.FinCollectionNoTicketMeta;
import com.dt.platform.domain.oa.meta.FinCompanySubjectMeta;
import com.dt.platform.domain.oa.meta.FinPaymentNoTicketMeta;
import com.dt.platform.domain.oa.meta.ProjectMeta;
import com.dt.platform.generator.config.Config;
import com.dt.platform.oa.page.FinPaymentNoTicketPageController;
import com.dt.platform.proxy.oa.FinCompanySubjectServiceProxy;
import com.dt.platform.proxy.oa.FinPaymentNoTicketServiceProxy;
import com.dt.platform.proxy.oa.ProjectServiceProxy;
import com.foxnicweb.web.domain.contract.Contract;
import com.foxnicweb.web.domain.contract.meta.ContractMeta;
import com.foxnicweb.web.proxy.contract.ContractServiceProxy;
import com.github.foxnic.api.bpm.IntegrateMode;
import com.github.foxnic.generator.builder.view.config.DatePickerType;
import com.github.foxnic.generator.config.WriteMode;
import org.github.foxnic.web.domain.hrm.Employee;

public class FinNoPaymentTicketGtr extends BaseCodeGenerator {


    public FinNoPaymentTicketGtr() {
        super(OaTables.OA_FIN_PAYMENT_NO_TICKET.$TABLE,"876475835756838912");
    }

    public void generateCode() throws Exception {
        System.out.println(this.getClass().getName());

        cfg.getPoClassFile().addSimpleProperty(Employee.class,"originator","originator","originator");
        cfg.getPoClassFile().addSimpleProperty(FinCompanySubject.class,"companySubject","companySubject","companySubject");

        cfg.view().field(OaTables.OA_FIN_PAYMENT_NO_TICKET.ID).basic().hidden(true);
        cfg.view().field(OaTables.OA_FIN_PAYMENT_NO_TICKET.BUSINESS_CODE).search();


        cfg.view().field(OaTables.OA_FIN_PAYMENT_NO_TICKET.CREATE_TIME).search().range();


        cfg.getPoClassFile().addSimpleProperty(Project.class,"project","project","project");
        cfg.getPoClassFile().addSimpleProperty(Contract.class,"contract","contract","contract");


        cfg.view().field(OaTables.OA_FIN_PAYMENT_NO_TICKET.PROJECT_ID)
                .form().selectBox().queryApi(ProjectServiceProxy.QUERY_PAGED_LIST)
                .paging(true).filter(false).toolbar(false)
                .valueField(ProjectMeta.ID).
                textField(ProjectMeta.NAME).
                fillWith(FinPaymentNoTicketMeta.PROJECT).muliti(false);



        cfg.view().field(OaTables.OA_FIN_PAYMENT_NO_TICKET.CONTRACT_ID)
                .form().selectBox().queryApi(ContractServiceProxy.QUERY_PAGED_LIST)
                .paging(true).filter(false).toolbar(false)
                .valueField(ContractMeta.ID).
                textField(ContractMeta.TITLE).
                fillWith(FinPaymentNoTicketMeta.CONTRACT).muliti(false);



        cfg.view().search().inputLayout(
                new Object[]{
                        OaTables.OA_FIN_PAYMENT_NO_TICKET.STATUS,
                        OaTables.OA_FIN_PAYMENT_NO_TICKET.PAYMENT_STATUS,
                        OaTables.OA_FIN_PAYMENT_NO_TICKET.ORIGINATOR_ID,
                        OaTables.OA_FIN_PAYMENT_NO_TICKET.BUSINESS_CODE,
                },
                new Object[]{
                        OaTables.OA_FIN_PAYMENT_NO_TICKET.PAYMENT_LAST_DATE,
                        OaTables.OA_FIN_PAYMENT_NO_TICKET.CREATE_TIME,
                }
        );
        cfg.view().search().labelWidth(1,Config.searchLabelWidth);
        cfg.view().search().labelWidth(2,Config.searchLabelWidth);
        cfg.view().search().labelWidth(3,Config.searchLabelWidth);
        cfg.view().search().labelWidth(4,Config.searchLabelWidth);
        cfg.view().search().inputWidth(Config.searchInputWidth);




        cfg.view().field(OaTables.OA_FIN_PAYMENT_NO_TICKET.AMOUNT).form().validate().required().form().numberInput().defaultValue(0.0).scale(2);
      //  cfg.view().field(OaTables.OA_FIN_PAYMENT_NO_TICKET.TICKET_DATE).form().validate().required().form().dateInput().type(DatePickerType.date).defaultNow().format("yyyy-MM-dd").search().range();

        cfg.view().field(OaTables.OA_FIN_PAYMENT_NO_TICKET.CREATE_BY).table().disable(true);
        cfg.view().field(OaTables.OA_FIN_PAYMENT_NO_TICKET.UPDATE_BY).table().disable(true);
        cfg.view().field(OaTables.OA_FIN_PAYMENT_NO_TICKET.UPDATE_TIME).table().disable(true);
        cfg.view().field(OaTables.OA_FIN_PAYMENT_NO_TICKET.CREATE_TIME).table().disable(true);
        cfg.view().field(OaTables.OA_FIN_PAYMENT_NO_TICKET.FILE_IDS).table().disable(true);

        cfg.view().field(OaTables.OA_FIN_PAYMENT_NO_TICKET.PROJECT_ID).table().disable(true);
        cfg.view().field(OaTables.OA_FIN_PAYMENT_NO_TICKET.CONTRACT_ID).table().disable(true);




        cfg.view().field(OaTables.OA_FIN_PAYMENT_NO_TICKET.NOTES).table().disable(true);


        cfg.view().field(OaTables.OA_FIN_PAYMENT_NO_TICKET.AMOUNT).form().validate().required().form().numberInput().defaultValue(0.0).scale(2);

        cfg.view().field(OaTables.OA_FIN_PAYMENT_NO_TICKET.STATUS).form().checkBox().enumType(FlowProcessStatusEnum.class);

        cfg.view().field(OaTables.OA_FIN_PAYMENT_NO_TICKET.PAYMENT_STATUS).form().checkBox().enumType(FinPaymentStatusEnum.class);

        cfg.view().field(OaTables.OA_FIN_PAYMENT_NO_TICKET.ORIGINATOR_ID).table().fillBy("originator","name");
        cfg.view().field(OaTables.OA_FIN_PAYMENT_NO_TICKET.ORIGINATOR_ID).form().readOnly().form()
                .button().chooseEmployee(true);


        cfg.view().field(OaTables.OA_FIN_PAYMENT_NO_TICKET.PAYMENT_LAST_DATE).form().dateInput().type(DatePickerType.date).defaultNow().format("yyyy-MM-dd").search().range();

        cfg.view().field(OaTables.OA_FIN_PAYMENT_NO_TICKET.COLLECT_SUBJECT).form().validate().required();

        cfg.view().field(OaTables.OA_FIN_PAYMENT_NO_TICKET.PAYMENT_SUBJECT)
                .form().validate().required().form().selectBox().queryApi(FinCompanySubjectServiceProxy.QUERY_PAGED_LIST)
                .paging(true).filter(false).toolbar(false)
                .valueField(FinCompanySubjectMeta.ID).
                textField(FinCompanySubjectMeta.NAME).
                fillWith(FinPaymentNoTicketMeta.COMPANY_SUBJECT).muliti(false);


        cfg.view().field(OaTables.OA_FIN_PAYMENT_NO_TICKET.NOTES).form().textArea().height(150);

        cfg.view().field(OaTables.OA_FIN_PAYMENT_NO_TICKET.FILE_IDS).form().upload().acceptAllType().maxFileCount(3);
        cfg.view().form().labelWidth(70);
        cfg.view().formWindow().bottomSpace(50);
        cfg.view().formWindow().width(Config.baseFormWidth);

        cfg.view().form().addGroup("付款信息",
                new Object[] {
                        OaTables.OA_FIN_PAYMENT_NO_TICKET.AMOUNT,
                        OaTables.OA_FIN_PAYMENT_NO_TICKET.COLLECT_SUBJECT,
                },
                new Object[] {
                        OaTables.OA_FIN_PAYMENT_NO_TICKET.PAYMENT_SUBJECT,
                }
                , new Object[] {
                        OaTables.OA_FIN_PAYMENT_NO_TICKET.ORIGINATOR_ID,
                }

        );

        cfg.view().form().addGroup("其他信息",
                new Object[] {
                        OaTables.OA_FIN_PAYMENT_NO_TICKET.PROJECT_ID,
                        OaTables.OA_FIN_PAYMENT_NO_TICKET.CONTRACT_ID,
                        OaTables.OA_FIN_PAYMENT_NO_TICKET.NOTES,
                        OaTables.OA_FIN_PAYMENT_NO_TICKET.FILE_IDS,
                }
        );

        cfg.view().list().addJsVariable("PAGE_TYPE","[[${pageType}]]","pageType");
        cfg.view().form().addJsVariable("CUR_EMP_ID","[[${curEmpId}]]","curEmpId");
        cfg.view().form().addJsVariable("CUR_USER_NAME","[[${curUserName}]]","curUserName");

        cfg.view().list().operationColumn().addActionButton("付款管理","payMgr","payMgr");
        cfg.view().list().operationColumn().addActionButton("付款详情","payDtl","payDtl");




        cfg.bpm().form("oa_fin_payment_no_ticket");
        cfg.bpm().integrate(IntegrateMode.FRONT);

        //文件生成覆盖模式
        cfg.overrides()
                .setServiceIntfAnfImpl(WriteMode.IGNORE) //服务与接口
                .setControllerAndAgent(WriteMode.IGNORE) //Rest
                .setPageController(WriteMode.IGNORE) //页面控制器
                .setBpmEventAdaptor(WriteMode.IGNORE) //页面控制器
                .setFormPage(WriteMode.COVER_EXISTS_FILE) //表单HTML页
                .setListPage(WriteMode.COVER_EXISTS_FILE)
                .setExtendJsFile(WriteMode.IGNORE); //列表HTML页
        //列表HTML页
        //生成代码
        cfg.buildAll();
    }

    public static void main(String[] args) throws Exception {
        FinNoPaymentTicketGtr g=new FinNoPaymentTicketGtr();
        //生成代码
        g.generateCode();

        //移除之前生成的菜单，视情况执行
//        g.removeByBatchId("471622036347682816");
        //生成菜单
        //
      //  g.generateMenu(FinPaymentNoTicketServiceProxy.class, FinPaymentNoTicketPageController.class);
    }

}
